<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
{% load tags %}
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>{% block title %}Connecting {{ mem_grp_data.0.first_name }}{% endblock %}</title>
    <link href="/{{ media_url }}contifyuser/css/user_profile.css" media="screen, projection" rel="stylesheet" type="text/css"/>    

    {% block extracss %}{% endblock %}
    
    <meta name="robots" content="{% block robots %}index,follow{% endblock %}" />
</head>

<body>

        <input id="first_name_hidden" type="hidden" value="{{mem_grp_data.0.first_name}}"/>
        <input id="last_name_hidden" type="hidden" value="{{mem_grp_data.0.last_name}}"/>
        <input id="mem_city_hidden" type="hidden" value="{{mem_grp_data.0.mem_city}}"/>
        <input id="mem_country_hidden" type="hidden" value="{{mem_grp_data.0.mem_country}}"/>
        {% block user_profile_subpageheader %}
        <div class="subPageHeader">
                <div>            
                        <div class="nobreak"><a style="text-decoration: none;" href="/connectpeople/home"><span class="headerTitle"><strong>Connect People</strong></span></a></div>
                        <div class="noRightBreak topBarText"><a class="topBarLink" href="{% url contifyuser.views.logout_user %}"><span class="">Logout</span></a></div>
                        {% if isMyProfile %}
                            <div class="noRightBreak topBarText"><a class="topBarLink" href="/connectpeople/profile/{{ mem_grp_data.0.userid }}/edit/">Settings</a></div>
                        {% endif %}
                </div>        
        </div>
        {% endblock %}
        <div>
                {% block user_profile_leftmenu %}
                <div class="userProfilePic">
                        <div id="id_mem_photo">
                            {{ mem_grp_data.0.photo_path|thumbnail }}
                        </div>
                        <div>
                            {{ mem_grp_data.0.userid|user_profile }}
                        </div>
                        <div id="id_user_addr" class="userInfoText">
                             {{mem_grp_data.0.mem_city}}, {{mem_grp_data.0.mem_country}}
                        </div>                        
                </div>
                {% endblock %}
                {% block user_profile_activity %}
                <div class="nobreak activitiy">
                    <div class="nobreak clearbreak activityStartLine">
                        &nbsp;
                    </div>                    
                    {% for each_activity in activity_dict %}
                    <div class="nobreak clearbreak eachActivitySection">
                        <div class="nobreak clearbreak eachActivity">
                            <div class="nobreak eachActivityLeft">
                                &nbsp;
                            </div>
                            <div class="nobreak eachActivityMiddle">
                                <div id="activity_{{ each_activity.0 }}">
                                    <strong>{{each_activity.2}}</strong>
                                </div>
                                <div class="nobreak clearbreak likeLink otherActivityMargin" id="other_act">
                                    <a href="#" id="other_act_{{ each_activity.0 }}" class="other_act_like">like</a>
                                </div>
                                {% if each_activity.6 %}
                                    <div class="nobreak clearbreak likeLink otherActivityMargin">
                                        <div class="nobreak">
                                            Liked by: 
                                        </div>
                                    {% for other_activity in each_activity.6%}
                                        <div class="nobreak" id="other_activity_{{ other_activity.0 }}">
                                            {% if forloop.counter > 1%}
                                                , 
                                            {% endif %}
                                            {{ other_activity.4|user_profile }}
                                        </div>                                  
                                    {% endfor %}
                                    </div>
                                {% endif %}
                                <div class="nobreak clearbreak otherActivityMargin">                           
                                    {% if each_activity.5 %}
                                        {% for comment in each_activity.5%}                                        
                                            <div class="nobreak clearbreak activitySubSection" id="comment_{{ comment.0 }}">
                                                <div class="nobreak clearbreak">
                                                    {{ comment.3|user_profile }}: <strong>{{ comment.2 }}</strong>
                                                </div>
                                            </div>                                  
                                            <div class="nobreak clearbreak likeLink" id="comm_other_act">                                                
                                                <div class="nobreak">
                                                    {{ comment.1 }} 
                                                </div>
                                                <div class="nobreak otherActivityMargin">
                                                    <a href="#" id="comm_other_act_{{ comment.0 }}" class="other_act_like">like</a>
                                                </div>
                                                </div>
                                            {% if comment.4 %}
                                                <div class="nobreak clearbreak likeLink">
                                                    <div class="nobreak">
                                                        Liked by: 
                                                    </div>                                            
                                                {% for comm_other_activity in comment.4 %}
                                                    <div class="nobreak" id="comment_other_activity_{{ comm_other_activity.0 }}">
                                                        {% if forloop.counter > 1%}
                                                            , 
                                                        {% endif %}
                                                        {{ comm_other_activity.4|user_profile }}
                                                    </div>                       
                                                {% endfor %}
                                                </div>
                                            {% endif %}                                    
                                        {% endfor %}
                                    {% endif %}
                                    <div class="nobreak clearbreak activitySubSection">
                                        <div class="nobreak clearbreak">
                                            <textarea id="{{ each_activity.0 }}" class="comment commentArea"></textarea>
                                        </div>
                                        <div class="nobreak clearbreak">
                                            <input id="submit_comment" activity_id="{{ each_activity.0 }}" type="button" value="Comment" class="postComment"/>                                                              
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="nobreak eachActivityRight">
                                <div class="nobreak clearbreak">
                                    {{ each_activity.4|user_profile }}
                                </div>
                                <div class="nobreak clearbreak">
                                    {% if each_activity.3 = 'New Discussion' %}
                                        New Discussion
                                    {% endif %}
                                    {% if each_activity.3 = 'Create Poll' %}
                                        New Poll
                                    {% endif %}                        
                                    {% if each_activity.3 = 'Poll Voted' %}
                                        New Vote
                                    {% endif %}
                                    {% if each_activity.3 = 'Create Event' %}
                                        New Event
                                    {% endif %}
                                    {% if each_activity.3 = 'RSVP to Event' %}
                                        New RSVP
                                    {% endif %}
                                    {% if each_activity.3 = 'Comment on Event' %}
                                        New Comment to Event
                                    {% endif %}
                                    {% if each_activity.3 = 'Group Information Update' %}
                                        Group Information Updated
                                    {% endif %}
                                    {% if each_activity.3 = 'Comment on Discussion' %}
                                        New Comment on Discussion
                                    {% endif %}
                                    {% if each_activity.3 = 'New Announcement' %}
                                        New Announcement Posted
                                    {% endif %}
                                    {% if each_activity.3 = 'New Idea' %}
                                        New Idea Posted
                                    {% endif %}	                                   
                                </div>                                
                                <div class="nobreak clearbreak">
                                    {{ each_activity.1 }}
                                </div>                                
                            </div>
                            
                        </div>
                    </div>
                    {% endfor %}                    
                    <div class="nobreak clearbreak activityEndLine">
                        &nbsp;
                    </div>                    
                </div>
                {% endblock %}
                {% block user_profile_rightmenu %}
                <div class="verticalRightBlock">                     
                    <div class="nobreak clearbreak box">
                        {% if mem_grp_data %}
                            Owned:<br>
                            <ul type="none">                                        
                            {% for group in mem_grp_data %}
                                {% if group.permission == 4 %}
                               <li>
                                    <div id="{{ group.group_web_address }}">
                                        <div>
                                            <a href="/connectpeople/group/{{ group.group_web_address }}">{{ group.group_name }}</a>
                                            <a href="#" gwebaddr="{{ group.group_web_address }}" class="delGroup">
                                                    <img class="groupTrashImg" title="delete" src="/{{ media_url }}/StartGroup/images/trash_icon.png"/>
                                            </a>
                                        </div>
                                        <div>{% if mem_group.group_city %}
                                                {{ mem_group.group_city }},
                                             {% endif %}
                                             {% if mem_group.group_country %}
                                                {{ mem_group.group_country }}
                                             {% endif %}
                                        </div>
                                        <div>{{ group.num_members }} </div>
                                    </div>
                               </li>
                               {% endif %}
                            {% endfor %}
                            </ul>
                        {% endif %}
                        <br />
                        <br />                           
                    </div>
                     <div class="nobreak clearbreak box">
                        {% if mem_grp_data %}
                            Member Of:<br>
                            <ul type="none">                                        
                            {% for mem_group in mem_grp_data %}
                                {% if mem_group.group_web_address %}
                                    {% if mem_group.permission > 0 and mem_group.permission < 4 %}                                    
                                        <!-- Redirect to group -->
                                       <li>
                                            <div><a href="/connectpeople/group/{{mem_group.group_web_address }}">{{ mem_group.group_name }}</a></div>
                                            
                                            <div>{% if mem_group.group_city %}
                                                    {{ mem_group.group_city }},
                                                 {% endif %}
                                                 {% if mem_group.group_country %}
                                                    {{ mem_group.group_country }}
                                                 {% endif %}
                                            </div>
                                            <div>{{ mem_group.num_members }} </div>
                                       </li>
                                    {% endif %}
                                {% endif %}
                            {% endfor %}
                            </ul>
                        {% endif %}
                        <br />
                        <br />
                           
                    </div>
                    <div class="nobreak clearbreak">
                    {% if isMyProfile %}
                        <a href="{% url StartGroup.views.startNewGroupForm %}">Start New Group</a>
                    {% endif %}
                    </div>
                    {% block user_profile_calendar %}
                    <div class="nobreak clearbreak">
                        <div class="nobreak clearbreak">
                            <a id="cal_prev">prev</a>
                            <span id="calendar_month">{% now "F" %} </span>
                            <span id="calendar_year">2010</span>
                            <a id="cal_next">next</a>
                            <input type="hidden" id="calendar_int_month" value="{% now "m" %}"/>
                        </div>
                        <div class="nobreak clearbreak each_month">
                                <div class="nobreak clearbreak">
                                    <div class="nobreak cal_column">Sun</div>
                                    <div class="nobreak cal_column">Mon</div>
                                    <div class="nobreak cal_column">Tue</div>
                                    <div class="nobreak cal_column">Wed</div>
                                    <div class="nobreak cal_column">Thu</div>
                                    <div class="nobreak cal_column">Fri</div>
                                    <div class="nobreak cal_column">Sat</div>                                    
                                </div>
                                <div id="calendar">
                                    {{ cal_month }}
                                <div>
                        </div>
                    </div>
                    {% endblock %}
                </div>
                {% endblock %}
        </div>

        <!-- Event Summary div -->
        <div id="id_event_summary" class="eventSummaryDiv" style="display:none;">
            <div class="eventSummaryClose">
                <img id="id_event_summary_close" class="eventSummaryCloseImg" src="/{{ media_url }}images/close.png"/>
            </div>
            <div class="eventSummaryEditHeader">
                Event Summary
            </div>
            <div id="id_event_summary_content"></div>
        </div>

{% block user_profile_settings %}
{% endblock %}
{% block extrajs %}
    <script src="/{{ media_url }}contifyuser/js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function(){$("#id_event_summary_close").click(function(){                                
                $("#id_event_summary").fadeOut('slow');
            });
        });
        
    
        $(document).ready(function(){$("a.delGroup").click(function(){
            var gwebaddr = $(this).attr('gwebaddr');
            
            var isDelete=confirm("Are you sure you want to delete this group?");
            if (isDelete)
                    jQuery.ajax({
                            url: '/connectpeople/home/',
                            type: 'POST',
                            data: {'action': 'Delete_Group', 'gwebaddr':gwebaddr},
                            dataType: 'json',
                            success: function(json){
                                    document.getElementById(gwebaddr).style.display="none";
                          },
                            error: function(xhr, ajaxOptions, thrownError){
                                    alert("An Error Has Occurred. Please try again.");
                            }
                          });
                    
            else
            {
                    alert("Aap achhe insaan ho. Khuda aapko bachhe de !! :)");
            }
            
            });
        });
        
	 $(document).ready(function(){$("input.postComment").click(function(e){
	    var comm_id = "#" + $(this).attr('activity_id');
            var comment_div = $(comm_id);
	    jQuery.ajax({
	      url: '/connectpeople/home/',
	      type: 'POST',
	      data: {'action': 'NEW_DISCUSSION_ACTIVITY_COMMENT_POSTED', 'comment': comment_div.val(), 'acti_id': $(this).attr('activity_id')},
	      dataType: 'json',
	      success: function(json){
		alert("success");
	    },
	      error: function(xhr, ajaxOptions, thrownError){
		alert("An Error Has Occurred. Please try again.");
	      }
	    });
	  });
	  });
         
        // Other Activity Ajax method
        $(document).ready(function(){$("a.other_act_like").click(function(e){
	    var comm_id = "#" + $(this).attr('activity_id');
            var comment_div = $(comm_id);
	    jQuery.ajax({
	      url: '/connectpeople/home/',
	      type: 'POST',
	      data: {'action': 'NEW_DISCUSSION_ACTIVITY_LIKED', 'type': 'LIKE', 'value': 1, 'index': $(this).attr('id')},
	      dataType: 'json',
	      success: function(json){
		alert("success");
	    },
	      error: function(xhr, ajaxOptions, thrownError){
		alert("An Error Has Occurred. Please try again.");
	      }
	    });
	  });
	  });
        
        // Get number of days in a month       
        var daysInMonth = function(month, year){
            return new Date(year, month, 0).getDate();
        }
                
        var monthName = function(month){
            if (month == 1)
            {
                return "January";
            }
            else if (month == 2)
            {
                return "February";
            }
            else if (month == 3)
            {
                return "March";
            }
            else if (month == 4)
            {
                return "April";
            }
            else if (month == 5)
            {
                return "May";
            }
            else if (month == 6)
            {
                return "June";
            }
            else if (month == 7)
            {
                return "July";
            }
            else if (month == 8)
            {
                return "August";
            }
            else if (month == 9)
            {
                return "September";
            }
            else if (month == 10)
            {
                return "October";
            }
            else if (month == 11)
            {
                return "November";
            }
            else if (month == 12)
            {
                return "December";
            }               
        }      
        
        $(document).ready(function(){$("#cal_prev").click(function(e){
            // Get year, month and increment them
            var year = $("#calendar_year").html();
            var month = $("#calendar_int_month").val();
            if (month == 1)
            {
                new_year = parseInt(year) - 1;
                new_month = 12;
            }
            else
            {
                new_year = year;
                new_month = parseInt(month) - 1;
            }
            $("#calendar_int_month").val(new_month);
            $("#calendar_year").html(new_year);
            txt_month = monthName(new_month);
            $("#calendar_month").html(txt_month);
           
            // Ajax request to update the calendar
            jQuery.ajax({
             url: '/connectpeople/home/',
             type: 'POST',
             data: {'action': 'CALENDAR_UPDATE', 'year': new_year, 'month': new_month},
             dataType: 'json',
             success: function(json){
                $("#calendar").html(json.cal_month)
            },
             error: function(xhr, ajaxOptions, thrownError){
               alert("An Error Has Occurred. Please try again.");
             }
           });
         });
         });         
        
        $(document).ready(function(){$("#cal_next").click(function(e){
            // Get year, month and increment them
            var year = $("#calendar_year").html();
            var month = $("#calendar_int_month").val();
            if (month == 12)
            {
                new_year = parseInt(year) + 1;
                new_month = 1;
            }
            else
            {
                new_year = year;
                new_month = parseInt(month) + 1;
            }
            // update html and hidden values
            $("#calendar_int_month").val(new_month);
            $("#calendar_year").html(new_year);
            txt_month = monthName(new_month);
            $("#calendar_month").html(txt_month);
           
            // Ajax request to update the calendar
            jQuery.ajax({
             url: '/connectpeople/home/',
             type: 'POST',
             data: {'action': 'CALENDAR_UPDATE', 'year': new_year, 'month': new_month},
             dataType: 'json',
             success: function(json){
                $("#calendar").html(json.cal_month)
            },
             error: function(xhr, ajaxOptions, thrownError){
               alert("An Error Has Occurred. Please try again.");
             }
           });
         });
         });        
        
        // Show Event summary
        $(document).ready(function(){$("a.event_day").click(function(e){
            var events = $(this).attr('event_ids');
            var eve_array = new Array();
            var eve_summary = "";
            eve_array = events.replace("[", "").replace("]","").split(",");
            for (i=0; i<eve_array.length;i++)
            {
                eve_id = eve_array[i].replace("L","").replace(" ", "");
                
                // Compose event id of hidden element and get summary elements
                eve_hdn = "#event" + eve_id;
                event_name = $(eve_hdn).attr("event_name");
                group_web_address = $(eve_hdn).attr("event_group");
                group_name = $(eve_hdn).attr("group_name");
                eve_summary += "<div class='eventSummaryEachDiv'><div><a href='/connectpeople/" + group_web_address + "/groupevents/" + eve_id + "'>" + event_name + "</a></div><div>" + group_name + "</div></div><hr>";
            }
            $("#id_event_summary_content").html(eve_summary);
            $("#id_event_summary").fadeIn('slow');
        }); 
        });        
    </script>
{% endblock %}

</body>



</html>


